package com.lms.time;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-06-29 15:25
 * @Description:
 */
public class LocalTimeDemo {
    public static void main(String[] args) {
        //23:59:59.999999999
        LocalTime max = LocalTime.MAX;
        //00:00
        LocalTime min = LocalTime.MIN;
        //00:00
        LocalTime midnight = LocalTime.MIDNIGHT;
        //12:00
        LocalTime noon = LocalTime.NOON;
        //15:29:55.476
        LocalTime now = LocalTime.now();

        int hour = now.getHour();
        int minute = now.getMinute();
        int second = now.getSecond();
        int nano = now.getNano();
        int i1 = now.get(ChronoField.NANO_OF_SECOND);
        LocalTime localTime = now.plusHours(2);
        LocalTime localTime1 = now.minusMinutes(2);
        LocalTime localTime2 = now.withMinute(30);
        LocalTime with = now.with(ChronoField.SECOND_OF_MINUTE, 59);
        LocalTime of = LocalTime.of(19, 59, 59);
        //结合这个时间与创建一个 LocalDateTime的日期。
        LocalDateTime localDateTime = now.atDate(LocalDate.of(2020, 9, 1));
        String format = now.format(DateTimeFormatter.ofPattern("HH时 mm分 ss秒"));
        String format1 = localDateTime.format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH时 mm分 ss秒 SSS纳秒"));
        LocalTime parse = LocalTime.parse("17时59分00秒",DateTimeFormatter.ofPattern("HH时mm分ss秒"));
        LocalDateTime parse1 = LocalDateTime.parse("2020年10月1日 17时59分00秒", DateTimeFormatter.ofPattern("yyyy年MM月d日 HH时mm分ss秒"));
    }
}
